package com.share.device.controller;

import com.share.common.rabbit.MqConstant.MqConst;
import com.share.common.rabbit.MqSender.Sender;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;

@RestController
@RequestMapping("/test")
@Slf4j
public class TestController {

    @Autowired
    private Sender sender;

    @GetMapping("/send")
    public String sendTestMessage() {
        try {
            String testMessage = "Test message at " + new Date();
            sender.sendRedis("test-message", testMessage);
            log.info("发送测试消息: {}", testMessage);
            return "消息发送成功";
        } catch (Exception e) {
            log.error("发送测试消息失败", e);
            return "消息发送失败: " + e.getMessage();
        }
    }
}
